package com.yangoxix.lovegoing.util;

import org.springframework.stereotype.Component;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;

/**
 * The type Time util.
 *
 * @program: lovegoing
 * @description: 时间的工具类
 * @author: chenzou
 * @create: 2021 -09-23 09:17
 */
@Component
public class timeUtil {
    /**
     * Gets current time.//    获取当前时间
     *
     * @return the current time
     */
    public static Instant getCurrentTime() {
        Instant now = Instant.now().plusMillis(TimeUnit.HOURS.toMillis(8));
        return now;
    }

    /**
     * Gets after day.//    获取未来的时间(天）
     *
     * @param day the day
     * @return the after day
     */
    public static Instant getAfterDay(int day) {
        Instant currentTime = getCurrentTime();
        Instant then = currentTime.plus(day, ChronoUnit.DAYS);
        return then;
    }

    /**
     * Gets afterhour.//    获取未来的时间（小时）
     *
     * @param hours the hours
     * @return the afterhour
     */
    public static Instant getAfterhour(int hours) {
        Instant currentTime = getCurrentTime();
        Instant then = currentTime.plus(hours, ChronoUnit.HOURS);
        return then;
    }
}
